import redis
from insects_detection.project_utils import project_tools
from insects_utils import insects_tools
import json
import time
#获取工作目录路径
project_root_dir=project_tools.project_root_path()+'\\'+'insects_detection'
# gallery_path="D:\\1Learning\江苏大学\虫害识别图像数据\四月份数据"
gallery_path='D:\\1Learning\江苏大学\虫害识别图像数据\第二次病虫害数据图像（03.03）'
# gallery_path = project_root_dir+'\\'+project_tools.insects_img_dirname
processed_gallery_path=project_root_dir+'\\'+project_tools.processed_img_dirname
chas_data_path=project_root_dir+'\\'+project_tools.characteristic_dirname
model_path=project_root_dir+'\\'+project_tools.models_dirname+'\\'+project_tools.model_name

r=redis.StrictRedis(host='39.102.44.159', port=6379, db=0, password='inetlabredis', decode_responses=True)
scaler_path='D:\python\workspace\insects_detection\\trainning_models\Model4April_scaler.pkl'
detailed_insects_info = insects_tools.classify_green_house_insects(chas_data_path,model_path,scaler_path)
detailed_insects_info_json = json.dumps(detailed_insects_info,ensure_ascii=False)
info_key = 'insects:'+time.strftime("%Y-%m-%d", time.localtime())
r.set(str(info_key), detailed_insects_info_json)
print(r.get(info_key))

